<?php 
include "includes/session.php";
include "includes/comunes.php";
require_once("includes/paginator.class.php");
error_reporting(0);
$pages = new Paginator;
$ano=date("Y");
$mes=date("m");
$where=" 1=1";
//armo el Where de la consutla

//if(!isset($_GET['submit']))
//    $where.=" and vendido=0";

 
if($_GET['fechaD']<>"")
     $where.=" and pagoFecha >='".$_GET['fechaD']."'";
	 else
	 $where.="  and pagoFecha >='".$ano."-".$mes."-1'";
if($_GET['fechaH']<>"")
     $where.=" and pagoFecha <='".$_GET['fechaH']."'";
	 else
	 $where.=" and pagoFecha <='".$ano."-".$mes."-27'";
	 
if($_GET['cliente']<>""){
$cli=explode("-",$_GET['cliente']);
   $where.=" and pagoCliente =".$cli[0];
}
    
    

//realizo la consulta paro obtener los totales
$tabla="pagoscuota";
$condicion=" ".$where;
$orden=" order by  pagoFecha desc";
$result=  cons_sql($tabla, $condicion, $orden);
//finc consulta

$pages->items_total = mysql_num_rows($result);
$pages->mid_range = 9;
$pages->paginate();

//echo $where.$_GET['tipo'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta HTTP-EQUIV="refresh" CONTENT="300"/>
<title>Sistema de Gestion de Vehiculos</title>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="estilos.css" rel="stylesheet" type="text/css" />

<!--libreria jquery central-->

<script src="jquery-ui/js/jquery-1.9.1.js"></script>
<!--fin libreria central-->

<!--Librerias para el combo-->
<script language="JavaScript" type="text/javascript" src="combos/jquery.chainedSelects.js"></script>
<!--fin libreria-->

<!--librerias ui-->
<link href="jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css" rel="stylesheet"/>
<script src="jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<!--fin libreria-->
<!--libreria flexigrid-->
<link rel="stylesheet" type="text/css" href="jquery-ui/css/ui-flexigrid/flexigrid.css">
    <script type="text/javascript" src="jquery-ui/js/flexigrid.js"></script>
<!--fin libreria-->



<script language="JavaScript" type="text/javascript">
$(function()
{

//        funcion que implementa combos
	$('#marca').chainSelect('#modelo','combomarcamodelo.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
        $('#modelo').chainSelect('#version','combomodeloversion.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
        
           $('#venpro').chainSelect('#venloc','comboprolocalidad.php',
	{
		before:function (target) //before request hide the target combobox and display the loading message
		{
			$("#loading").css("display","block");
			$(target).css("display","none");
		},
		after:function (target) //after request show the target combobox and hide the loading message
		{
			$("#loading").css("display","none");
			$(target).css("display","inline");
		}
	});
        
//        fin funcion

//          funcion datapicker

       $( "#fechaD" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
	  
	  $( "#fechaH" ).datepicker({
         dateFormat: "yy-mm-dd"

      });
       
//             funcion

//funcion autocomplete
                $( "#patente" ).autocomplete({
			source: "autoPatentes.php"
		});

//fin funcion

 $( "#cliente" ).autocomplete({
			source: "autoCliente.php"
		});


  $('#flex1').flexigrid({
      colModel : [
                
		{display: 'Boleto', name : 'patenteId', width : 30, sortable : true, align: 'center'},
		{display: 'Cliente', name : 'fecha', width : 150, sortable : true, align: 'left'},
		{display: 'Cuota', name : 'estado', width : 30, sortable : true, align: 'left'},
		{display: 'Fec.Pago', name : 'origen', width : 65, sortable : true, align: 'left'},
		{display: 'Abonado', name : 'destino', width : 60, sortable : true, align: 'left'},
				{display: 'Punitorios', name : 'creado', width : 60, sortable : true, align: 'left'},
                 {display: 'Total', name : 'dias', width : 60, sortable : true, align: 'left'},
		],
                width: 450,
                height: 1000
              
  });
<?php for ($i=1;$i<30;$i++):?>
  $('#fila<?php echo $i?>').tooltip({
      track: true
    });
 
<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#visualizar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
 <?php for ($i=1;$i<30;$i++):?>
  $('#editar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#imprimir<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
<?php for ($i=1;$i<30;$i++):?>
  $('#tratar<?php echo $i?>').tooltip({
      track: true
    });

<?php endfor?>
});
</script>



</head>

<body>

<div class="container">
<?php include "includes/head.php"?>
   <div class="content">
       <div class="tituloprincipal">
           <?php include 'includes/submenu.php';?>  
           <img src="img/pedidos.jpg" width="25" height="25" border="0"/> Reporte de Cobranzas de Cuotas
           </div>
       
       <div class="contenedorpedido">
       <form id="altavehiculo" name="altavehiculo" method="GET" action="ReporteVencimientos.php">
        <fieldset>
             <legend><b>Seleccione Filtros</b></legend>
             <table width="100%">
                
                 <tr>
                    <td class="textotablamenuform">Fecha Desde</td>
                    <td class="textotablamenuform"><input type="text" name="fechaD" id="fechaD" value="" class="campo_form" required/></td>
                     <td class="textotablamenuform">Fecha Hasta</td>
                    <td class="textotablamenuform"><input type="text" name="fechaH" id="fechaH" value="" class="campo_form" required/></td>
                      
                        </tr>
						<tr>
                     <td class="textotablamenuform">Cliente</td>
                    <td class="textotablamenuform" colspan="5"><input type="text" name="cliente" id="cliente" value="" class="campo_form" /></td>
                      
                        </tr>
                 <tr>
<!--                    <td class="textotablamenuform">Sucursal</td>
                    <td class="textotablamenuform" ><select name="sucursal" id="sucursal" class="campo_form">
                      <option selected="selected" value="0">Todos...</option>
                      <?php
//                             $ped=obtener_sucursales();

//                             while($regPed=mysql_fetch_array($ped)){
//                                 
//                                       echo "<option value='".utf8_encode($regPed['sucursalId'])."'>".utf8_encode($regPed['sucursalNombre'])." (".utf8_encode($regPed['sucursalCodigo']).")</option>";
//
//
//                             }

                             ?>
                    </select></td>-->
                 </tr>
                   <tr>
                    <td class="textotablamenuform" style="text-align: right;" colspan="8">
                         <input type="reset" name="enviar" value="Limpiar"  class="boton_form"/>
                         <input name="submit" id="submit" type="submit" value="Realizar Busqueda" class="boton_form"/>
                     </td>
                 </tr>
             </table>
        </fieldset>
       </form>
           <fieldset>
             <legend><b>Resultado de la Busqueda</b></legend>
             
             </br>

             <table id="flex1">

               <tbody>

                <?php
                $i=1;
				$totalCapital=0.00;
				$totalPuntitorios=0.00;
				$total=0.00;
                if($pages->items_total >0)
                while($reg=  mysql_fetch_array($result)):?>
                  <tr id="fila<?php echo $i?>">
                     
                     <td><?php echo $reg['pagoBoleto']?></td>
                     <td><?php echo obtener_nombre_personas($reg['pagoCliente'])?></td>
                     <td><?php echo $reg['pagoCuota']?></td>
                     <td><?php echo format_fec($reg['pagoFecha'],"/")?></td>
                     <td>$ <?php echo $reg['pagoAbonado']?></td>
                     <td>$ <?php echo $reg['pagoPunitorios']?></td>
					 <td>$ <?php echo  $reg['pagoAbonado']+$reg['pagoPunitorios'] ?></td>
                     
					
                  </tr>
                 <?php
				   $totalCapital+=$reg['pagoAbonado'];
				   $totalPunitorios+=$reg['pagoPunitorios'];
				   $total+=($reg['pagoAbonado']+$reg['pagoPunitorios']);
				 
                 $i++;
                 endwhile
                
                 ?>
				 <tr">
                     
                     <td ></td>
                     <td ></td>
                     <td ></td>
                     <td ><b>Totales</b></td>
                    
                     <td><b>$ <?php echo  $totalCapital ?></b></td>
                     <td><b>$ <?php echo  $totalPunitorios ?></b></td>
                     
                       <td><b>$ <?php echo  $total ?></b></td>
                     
					 
                  </tr>

                  
                </tbody>

             </table>
             

        </fieldset>
           
       </div>
 
       <div class="clear"></div>
   <br>
   </div>
  <?php include "includes/pie.php"?>
  
</div>
</body>
</html>
